﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace pxt
{
    public class Charge
    {
        // Members
        protected TongaTimer mTimer;
        protected bool mFullyCharged;
        protected StatusBar mCastBar;
        protected BaseCharacter mOwner;


        // Functions
        public Charge(double full_charge_time, BaseCharacter own)
        {
            mOwner = own;
            mTimer = new TongaTimer(full_charge_time);
            mFullyCharged = false;
            mCastBar = new StatusBar(new Vector2(0.2f, 0.2f), Color.Beige, Color.DarkGoldenrod);
        }

        public void Update(GameTime gt)
        {
            mTimer.Update(gt);
            //Console.WriteLine("Current Charged Time = " + mTimer.ElapsedTime);
            if (mTimer.Check())
            {
                mFullyCharged = true;
            }
            mCastBar.Update(gt, ( (float)(mTimer.ElapsedTime)/(float)(mTimer.Time) ));
        }

        public void Draw()
        {
            // TODO: Draw the charge meter and the line
            mCastBar.Draw(mOwner.Position + new Vector2(5.0f, -15.0f));
        }

        public void Reset()
        {
            mTimer.Reset();
            mFullyCharged = false;
        }

        // Properties
        public bool IsFull
        {
            get { return mFullyCharged; }
        }
    }
}
